
        
     <script type="text/javascript" >
          //modify
          var url = getUrl()+ "services/BasicManageService";
          
          var griddata =  new Array();
          var deletedata=new Array();
          var querydata =  new Array();
          formatDate = function(inDatum){
                                  		 	}
          var model = new dojox.grid.data.Table(null, griddata);
          var layout =[{type: 'dojox.GridRowView', width:'10px'},{
                       
             cells: [
                      [
                       { name: 'choise', width: 3, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },//
                       { name: 'No.', width: 2, styles: 'text-align: center;', get: function(inRowIndex){ return inRowIndex+1;} },//
                       { name: 'fieldName', field: 2,width: 20, editor: mydojo.ValidationTextBox ,required:true ,maxLength:30,invalidMessage:'can not be empty'},
                       { name: 'enumerationType', field: 3,width: 20} 
                        //editor: mydojo.ValidationTextBox ,required:true ,maxLength:30,invalidMessage:'can not be empty'}
                        //,{name: 'parentId',field:4, width: 8,editor: dojox.grid.editors.Dijit, editorClass: "dijit.form.NumberTextBox", constraint: {min:0,max:9999999,places:4} }

                         ]
                     ]
                          }];
                                                                    
       function call_funUpd() {
   
           var s = grid.selection.getSelected();
           for(var i=0;i<s.length;i++){
             var ii=s[i];
             var thisCell=grid.model.data[ii];
             var padd = new SOAPClientParameters2();
             var vobject=new Object();
             vobject.id=thisCell[1];
             if(dojox.validate.isText(thisCell[2], {minlength: 1})){vobject.fieldName=thisCell[2];
             }else{grid.getCell(ii).getNode(2).innerHTML="<p style={color:red}>can not be null</p>"; continue;}//not null
             if(dojox.validate.isText(thisCell[3], {minlength: 1})){vobject.enumerationType=thisCell[3];
             }else{grid.getCell(ii).getNode(3).innerHTML="<p style={color:red}>can not be null</p>"; continue;}//not null
             vobject.parentId=thisCell[4];
            /* if(dojox.validate.isInRange(thisCell[4],{max:9999999, min:0})){vobject.parentId=thisCell[4];
             }else{grid.getCell(ii).getNode(4).innerHTML="<p style={color:red}>can not be double</p>";continue;}//double*/
             //alert(vobject.id);
            // alert(vobject.fieldName);
             if(thisCell[1]==0){//create new row
                padd.add('EnumerationVO',vobject);
                SOAPClient.invoke(url, "createEnumeration", padd, false,  function GetEnu_callBack(ul, soapResponse){
                grid.model.setDatum(ul,ii,1);
                });
	         }else{//modify row
                padd.add('enumerationVO',vobject);
                SOAPClient.invoke(url, "updateEnumerations", padd, false,  function GetEnu_callBack(ul, soapResponse){
                });
	         }
          }
//submit delete
          for(var i=0;i<deletedata.length;i++){
               var pdel = new SOAPClientParameters();      
               pdel.add('ids',deletedata[i]);
               SOAPClient.invoke(url, "deleteEnumerations", pdel, false,  function GetEnu_callBack(ul, soapResponse){
	             
	           });
          }
          deletedata=new Array();
          dojo.byId("rowCount").innerHTML = 'saved'; 
   }

 function removeSelectedRows(){
           var s = grid.selection.getSelected();
           for(var i=0;i<s.length;i++){ 
             var ii=s[i];
             var thisCell=grid.model.data[ii];
             if(thisCell[1]!=0){//the row which will be deleted
               deletedata.splice(deletedata.length,0,thisCell[1]);
             }
           }    
           grid.removeSelectedRows();
     }   
addRow = function(){
		//alert(queryenumerationType.getDisplayedValue());
		if(queryenumerationType.getDisplayedValue()==''){
		    alert("zhi ding leibie");
		}else{
		    grid.addRow([false,0,"",queryenumerationType.getDisplayedValue(),0],grid.model.getRowCount());
        } 
    }
//query


    var enumerationTypedata =  new Array();
 	 var pl = new SOAPClientParameters();
 	 //pl.add('parentType',1) ;//
     SOAPClient.invoke(url, "getEnumerationType", pl, false,  function GetEnu_callBack(ul, soapResponse){
     alert("ul:"+ul);
            if(null!=ul){
               for(var i = 0; i < ul.length; i++){		
                            //var ulo=ul[i];
                            //enumerationTypedata.push({name: ulo["ns:enumerationType"], value: ulo["ns:enumerationType"]});
                            enumerationTypedata.push({name: ul[i], value: ul[i]});
        		}  }
          });
     var enumerationTypestore = new dojo.data.ItemFileWriteStore({data: {identifier:"value", items: enumerationTypedata}});


          
function querybutton(){
              var p = new SOAPClientParameters2();
              var queryvo=new Object();
              queryvo.id=0 ;
		    queryvo.fieldName= '%'+queryfieldName.getDisplayedValue()+'%';//
		    queryvo.enumerationType= '%'+queryenumerationType.getDisplayedValue()+'%';//
		    queryvo.parentId=0;//double

              p.add('EnumerationVO',queryvo);
             /* p.add('pageNumber',0) ;
      		    p.add('pageSize',0) ;
      		    p.add('orderBy','%') ;*/
              SOAPClient.invoke(url, "getEnumeration", p, false,  function GetEnu_callBack(ul, soapResponse){   
                     querydata=new Array();  
                     if(null!=ul){      
                     for(var i = 0; i < ul.length; i++){		
                      var items = new Array();
                      var ulo=ul[i];
                        items[0] = false;
                        items[1] = ulo["ns:id"];
                        items[2] = ulo["ns:fieldName"];//
                        items[3] = ulo["ns:enumerationType"];//
                        items[4] = ulo["ns:parentId"];//
                      querydata[i]=items;
                    } }               
                });       
                model.setData(querydata); 
                 grid.update();
         }
 //????????????

 	
 function init(){ 
 //alert();
 }
 //
         
   /*var poptarts ={ label:'name',identifier:'eId',items:data};
   var popStore = new dojo.data.ItemFileWriteStore({data: poptarts});      
         
       
 		   var pl = new SOAPClientParameters();
           //pl.add('eType','??') ;
           pl.add('parentType',0) ;
           SOAPClient.invoke(url, "gGetEnumerationByParentId", pl, false,  function GetEnu_callBack(ul, soapResponse){
             var pInfo = {
                   					parent: null,		
                   					attribute: "children"	
                   		};
                   		//alert(ul.length);
               for(var i = 0; i < ul.length; i++){		
                            var ulo=ul[i];
                            popStore.newItem({name: ulo["ns:enumerationType"],type:ulo["fieldName"] ,eId:ulo["ns:id"]}, pInfo);
                            /*var items = new Array();
                             items[0] = false;
                             items[1] = ulo["ns:id"];
                             items[2] = ulo["ns:name"];
                             items[3] = ulo["ns:parCode"];
                             items[4] = ulo["ns:remark"];
                             placedata[i]=items;  
                       }
          });
           // _tree._expandNode(chNode);
           
          dojo.connect(_tree, "onClick", function(item,node){
            	    selectNode=node;
                    selectNodeIdentity = _tree.store.getIdentity(item);
                    var p0 = new SOAPClientParameters();
                    //alert(mainTabContainer.selectedChildWidget.id);
             
                    placedata = new Array();
                    p0.add('eType',item["name"]);
                    SOAPClient.invoke(url, "getEnumerationByType", p0, false,  function GetEnu_callBack(ul, soapResponse){   
                    for(var i = 0; i < ul.length; i++){		
                      var items = new Array();
                      var ulo=ul[i];
                        items[0] = false;
                        items[1] = ulo["ns:id"];
                        items[2] = ulo["ns:fieldName"];
                        items[2] = ulo["ns:enumerationType"];
                        placedata[i]=items;
                    }                
                });       
                model.setData(placedata);
                grid.selection.clear();
                deletedata =new Array(); 
           }           
    }            
        */
          dojo.addOnLoad(init); 
     </script>

<!-- div align="left" style="height:100%; width:50%" > </div-->

     	<div id="queryDiv" style=" {left:240px; height: 16%; display:'';}"  align="center"   >
     	
	                        <table  class="queryTable"  align="center" style=" {width:70% ;  }" >
	                        <tr height="3" ></tr>
						          <tr align="center"><td >Please input criterial:</td><td></td></tr> <tr height="6" ></tr>
                                <tr align="center" >
                                  <td align="right" >name:</td><td align="left" ><input type="text"  jsId="queryfieldName"   dojoType="dijit.form.TextBox"  /></td>
    
                                  <td align="right" >type:</td><td align="left" ><input dojoType="dijit.form.ComboBox" jsId="queryenumerationType" autoComplete="false"   store="enumerationTypestore" /></td>
					          </tr>
                                  <!-- tr height="6" ></tr>
                               <tr height="6" >
                                <td align="right" >parentId:</td> <td align="left" ><input type="text" jsId="queryparentId" dojoType="dijit.form.NumberTextBox"  /></td>
                        
					          </tr-->
                                  <tr height="6" ><td align="right" ></td><td align="right" ></td><td align="right" ></td><td align="right" ></td></tr>
	
                                  <tr align="center"><td></td><td></td><td></td><td ><a onclick="querybutton();"><img src="../image/332.gif" height="20" width="20" border="0">OK</a></td></tr> <tr height="6" ></tr>
						    </table>
	     </div>
	     <div  align="center" style="width:70%" >
	       	<div align="right"  >
	          		<a onclick="querydisplay();"><img src="../image/332.gif" height="20" width="20" border="0">query</a>
			        <a onclick="addRow();"><img src="../image/371.gif" height="20" width="20" border="0">add</a>
			        <a onclick="removeSelectedRows();"><img src="../image/808.gif" height="20" width="20" border="0">delete</a>
			        <a onclick="call_funUpd();"><img src="../image/334.gif" height="20" width="20" border="0">save</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
		 </div></div>   
	        
	      <div id="rowCount"  align="center" style="width:70% " ></div>
	         <div  style="width:70%;height:600px;" >
           <div id="grid"  dojoType="dojox.Grid" autoWidth="false" style="left:160px;" jsId="grid"	model="model"  structure="layout" singleClickEdit="true" >
           </div></div>

